// =========== thread for recording mode =========== //
void threadRec() {
  while (true) {
    drawArea.rec();
    if (drawArea.isnrecording()) {
      break;
    }
    delay(10);
  }
}

// =========== thread for scan mode, scan the mosue moving =========== //
void threadScan() {
  while (true) {
    drawArea.scan();
    delay(11); // make 11ms and 13 ms, they are prime number, make big common multiplier
  }
}

// =========== thread for scan mode, draw trace =========== //
// why make this dedicate thread? let 'threadScan' more precise
// seperate scanning and painting into 2 threads
void threadPaintDot() {
  while (true) {
    drawArea.paintTrace();
    delay(13); // make 11ms and 13 ms, they are prime number, make big common multiplier
  }
}

// =========== thread for showing pre-define trace 'tick' & 'cross' animation =========== //
void threadShowPreRecTrace() {
  while (true) {
    drawArea.showPreRecTrace(0);
    delay(20);
    if (!drawArea.isShowingPreRecTrace()) {
      println("show pre-recorded trace done");
      break;
    }
  }
}
